package com.lyb.spzx.product.controller;

import com.lyb.spzx.model.entity.product.Category;
import com.lyb.spzx.model.vo.common.Result;
import com.lyb.spzx.model.vo.common.ResultCodeEnum;
import com.lyb.spzx.product.service.CategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "分类商品接口管理")
@RestController
@RequestMapping("api/product/category")
//@CrossOrigin
public class CategoryController {

    @Autowired
    CategoryService categoryService;

    @Operation(summary = "查询所有分类")
    @GetMapping("/findCategoryTree")
    public Result<List<Category>> findAllCategory(){
        List<Category> categories = categoryService.findAllCategory();
        return Result.build(categories, ResultCodeEnum.SUCCESS);
    }
}
